<html>
    <head>
        <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
        <title>Pedir Citas</title>
        <link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="AQUA" />
        <script type="text/javascript" src="js/calendar.js"></script>
        <script type="text/javascript" src="js/calendar-en2.js"></script>
        <script type="text/javascript" src="calendar-setup.js"></script>
        <%@page import="java.util.ArrayList" %>
        <%@page import="java.util.List" %>
        <%@page pageEncoding="ISO-8859-1"%>

<%@page import="infb.modelo.Pacientes" %>
<%  

        String lmf = (String) request.getParameter("lmf");
        String apellido = (String) request.getParameter("apellido");
        String perfil = (String) session.getAttribute("perfil");
        String dniMedico=null;
        if(perfil.equals("paciente")){
             dniMedico=((Pacientes)session.getAttribute("usuario")).getMedico().getDni();
        }else{
             dniMedico=request.getParameter("medico");
        }
%>
    </head>
    <body>
<br/>
        <h1>Pedir Cita para el doctor: <%=apellido%></h1><br/>

    <div style="float: right; margin-left: 1em; margin-bottom: 1em;" id="calendar-container"></div>


    <script type="text/javascript">
    <%=lmf%>
    var medico="<%=dniMedico%>";
    var apellido="<%=apellido%>";
    function dateIsSpecial(year, month, day) {
        var m = SPECIAL_DAYS[month];
        if (!m) return false;
        for (var i in m) if (m[i] == day) return true;
        return false;
    };

    function dateChanged(calendar) {
        if (calendar.dateClicked) {
            var y = calendar.date.getFullYear();
            var m = calendar.date.getMonth();     // integer, 0..11
            var d = calendar.date.getDate();      // integer, 1..31

            m=m+1;
            a=y%100;

            if(d<10){dia="0"+d;}else{dia=d}
            if(m<10){mes="0"+m;}else{mes=m}
            if(a<10){anno="0"+a}else{anno=a}
            window.location = "HoraCita.do?fecha="+dia+"/"+mes+"/"+anno+"&medico="+medico+"&apellido="+apellido

        }
    };

    Calendar.setup(
    {
        flat         : "calendar-container",
        flatCallback : dateChanged,
        dateStatusFunc : function(date, y, m, d) {
            if (dateIsSpecial(y, m, d)) return "ocupado";
            else return false; // other dates are enabled
            // return true if you want to disable other dates
        }
    }
);
        </script>
</body>
</html>
